import { AdvancedSearch } from '@/src/components/index';
import { DATA_ENTRY, FirstHeaderC, SecondHeaderC } from '@/src/components';
import { PrimaryC } from '@/src/comps';
import moment from 'moment';
import { useRef, useState } from 'react';

export default () => {
  const INPUTNUMBERRef = useRef();
  const SELECTRef = useRef();
  return (
    <div>
      <FirstHeaderC title='测试InputC/InputNumberC/SelectC/RANGESELECT，点击查询结果打印到控制台' />
      <SecondHeaderC title='小于900' />
      <div style={{ width: 900 }}>
        <AdvancedSearch
          parentId={'xxxxx'}
          dataSource={[
            {
              dataIndex: 'SERIESPRODUCTGROUP',
              type: DATA_ENTRY.SERIESPRODUCTGROUP,
              initialValue: '11111111',
              disabled: true,
              rules: [{ required: true, message: '请选择系列产品!' }],
              span: 24,
            },
            {
              dataIndex: 'PRODUCTLIST',
              type: DATA_ENTRY.PRODUCTLIST,
              initialValue: '00465f0f1ad94c5e93c2b6560c08c6c0',
            },
            {
              dataIndex: 'PRODUCTGROUPTREE',
              helper: 'xxx',
              type: DATA_ENTRY.PRODUCTGROUPTREE,
              multiple: false,
            },
            { dataIndex: 'input', title: '输入框', type: DATA_ENTRY.INPUT, initialValue: 'xxxx' },
            {
              dataIndex: 'select',
              type: DATA_ENTRY.SELECT,
              allowClear: true,
              title: 'select下拉',
              dataSource: [
                { value: '1', title: '一' },
                { value: '2', title: '二' },
                { value: '3', title: '三' },
              ],
              initialValue: ['1'],
              // isMultiple: true,
              rules: [{ required: true, message: '不能为空!' }],
              onRef: (ref) => (SELECTRef.current = ref),
            },
            {
              dataIndex: 'treeselect',
              title: '树形下拉',
              type: DATA_ENTRY.TREESELECT,
              dataSource: [
                { value: '1', title: '下拉选择1', children: [{ value: '11', title: 'dddd' }] },
                { value: '2', title: '下拉选择2' },
                { value: '3', title: '下拉选择3' },
              ],
              initialValue: ['1'],
              // loading: this.state.loading,
              isMultiple: true,
              allowClear: true,
              onChange: (e) => console.log(e),
              // disabled: this.state.disabled,
            },
            {
              dataIndex: 'inputnumber',
              title: '数字输入',
              type: DATA_ENTRY.INPUTNUMBER,
              disabled: true,
              unit: '元',
              splitStyle: true,
              initialValue: 123,
              rules: [{ required: true, message: '请输入数字!' }],
              onRef: (ref) => (INPUTNUMBERRef.current = ref),
            },
            {
              dataIndex: ['rateRangeStart', 'rateRangeEnd'],
              title: '评级区间',
              type: DATA_ENTRY.RANGESELECT,
              // initialValue: ['1', '3'],
              dataSource: [
                [
                  { title: '开始1', value: '0' },
                  { title: '结束1', value: '1' },
                ],
                [
                  { title: '开始2', value: '2' },
                  { title: '结束2', value: '3' },
                ],
              ],
              // span: '24',
              // styleRow: { width: '30%' },
            },
            {
              dataIndex: 'singleDate',
              type: DATA_ENTRY.SINGLEDATE,
              title: ' 简单日期选择 ',
              disableBegin: moment('2023-05-01'),
              disableEnd: moment('2023-10-01'),
              initialValue: moment('2023-07-15'),
              rules: [{ required: true, message: '请选择' }],
              allowClear: true,
              helper: '选择日期',
            },
            {
              dataIndex: ['beginDate1', 'endDate1'],
              title: '当日之后',
              type: DATA_ENTRY.RANGEDATE,
              initialValue: [moment().add(0, 'day'), moment().add(1, 'year').subtract(1, 'day')],
              hasDataBD: moment().add(0, 'day'),
              disableFuture: false,
            },
            {
              dataIndex: 'simpleWeek',
              type: DATA_ENTRY.SIMPLEWEEK,
              // type: DATA_ENTRY.SIMPLEWEEK,
              title: ' 周选择 ',
              initialValue: moment('2020-06-01'),
              // dateBeginKey: '1',
              // rules: [{ required: true, message: '请选择' }],
              allowClear: true,
            },
            {
              dataIndex: ['beginDate', 'endDate'],
              title: '日期区间',
              type: DATA_ENTRY.RANGEDATE,
              initialValue: [moment().subtract(1, 'year'), moment().subtract(5, 'day')],
              hasDataED: moment().subtract(1, 'day'),
              allowClear: true,
            },
            {
              dataIndex: 'SimpleQuarterC',
              title: '季度选择',
              type: DATA_ENTRY.SIMPLEQUARTERC,
              highCurrentDate: false,
              initialValueQuarter: '3',
              yearKey: 'year1',
              quarterKey: 'quarter1',
              onQuarterChange: (data) => {
                console.log(data);
              },
              allowClear: true,
              rules: [[{ required: true, message: '请选择年份' }], [{ required: true, message: '请选择季度' }]],
            },
            {
              selectIndex: 'complextdate1',
              startIndex: 'begin1',
              endIndex: 'end1',
              title: '复杂日期区间',
              type: DATA_ENTRY.COMPLEXDATE,
              selfDefination: ['0', '1', '2', '3', '4', '5', '6', '7', '8'],
              startOnChange: (e) => console.log(e),
              endOnChange: (e) => console.log(e),
              // onRef: (ref) => (this.COMPLEXDATE = ref),
              // disabled: this.state.disabled,
            },
          ]}
          onQuery={(e) => {
            console.log(e);
          }}
          onClear={(e) => {
            console.log(e);
          }}
        />
      </div>
      <SecondHeaderC title='FormItem层级的initialValue' topHeight={true} />
      <AdvancedSearch
        dataSource={[
          { dataIndex: 'input', title: '输入框', type: DATA_ENTRY.INPUT, initialValue: 'xxxx' },
          {
            dataIndex: 'select',
            type: DATA_ENTRY.SELECT,
            allowClear: true,
            title: 'select下拉',
            dataSource: [
              { value: '1', title: '一' },
              { value: '2', title: '二' },
              { value: '3', title: '三' },
            ],
            initialValue: ['1'],
            // isMultiple: true,
            rules: [{ required: true, message: '不能为空!' }],
            onRef: (ref) => (SELECTRef.current = ref),
          },
          {
            dataIndex: 'treeselect',
            title: '树形下拉',
            type: DATA_ENTRY.TREESELECT,
            dataSource: [
              { value: '1', title: '下拉选择1', children: [{ value: '11', title: 'dddd' }] },
              { value: '2', title: '下拉选择2' },
              { value: '3', title: '下拉选择3' },
            ],
            initialValue: ['1'],
            // loading: this.state.loading,
            isMultiple: true,
            allowClear: true,
            onChange: (e) => console.log(e),
            // disabled: this.state.disabled,
          },
          {
            dataIndex: 'inputnumber',
            title: '数字输入',
            type: DATA_ENTRY.INPUTNUMBER,
            disabled: true,
            unit: '元',
            splitStyle: true,
            initialValue: 123,
            rules: [{ required: true, message: '请输入数字!' }],
            onRef: (ref) => (INPUTNUMBERRef.current = ref),
          },
          {
            dataIndex: ['rateRangeStart', 'rateRangeEnd'],
            title: '评级区间',
            type: DATA_ENTRY.RANGESELECT,
            // initialValue: ['1', '3'],
            dataSource: [
              [
                { title: '开始1', value: '0' },
                { title: '结束1', value: '1' },
              ],
              [
                { title: '开始2', value: '2' },
                { title: '结束2', value: '3' },
              ],
            ],
            // span: '24',
            // styleRow: { width: '30%' },
          },
        ]}
        onQuery={(e) => {
          console.log(e);
        }}
        onClear={(e) => {
          console.log(e);
        }}
      />
      <SecondHeaderC title='Form层级的initialValues，高于FormItem层级' topHeight={true} />
      <AdvancedSearch
        initialValues={{
          input: '高层及xxxx',
          select: ['2'],
          treeselect: ['1', '2', '3'],
          inputnumber: 456,
        }}
        dataSource={[
          { dataIndex: 'input', title: '输入框', type: DATA_ENTRY.INPUT, initialValue: 'xxxx' },
          {
            dataIndex: 'select',
            type: DATA_ENTRY.SELECT,
            allowClear: true,
            title: 'select下拉',
            dataSource: [
              { value: '1', title: '一' },
              { value: '2', title: '二' },
              { value: '3', title: '三' },
            ],
            initialValue: ['1'],
            // isMultiple: true,
            rules: [{ required: true, message: '不能为空!' }],
            onRef: (ref) => (SELECTRef.current = ref),
          },
          {
            dataIndex: 'treeselect',
            title: '树形下拉',
            type: DATA_ENTRY.TREESELECT,
            dataSource: [
              { value: '1', title: '下拉选择1', children: [{ value: '11', title: 'dddd' }] },
              { value: '2', title: '下拉选择2' },
              { value: '3', title: '下拉选择3' },
            ],
            initialValue: ['1'],
            // loading: this.state.loading,
            isMultiple: true,
            allowClear: true,
            onChange: (e) => console.log(e),
            // disabled: this.state.disabled,
          },
          {
            dataIndex: 'inputnumber',
            title: '数字输入',
            type: DATA_ENTRY.INPUTNUMBER,
            disabled: true,
            unit: '元',
            splitStyle: true,
            initialValue: 123,
            rules: [{ required: true, message: '请输入数字!' }],
            onRef: (ref) => (INPUTNUMBERRef.current = ref),
          },
          {
            dataIndex: ['rateRangeStart', 'rateRangeEnd'],
            title: '评级区间',
            type: DATA_ENTRY.RANGESELECT,
            // initialValue: ['1', '3'],
            dataSource: [
              [
                { title: '开始1', value: '0' },
                { title: '结束1', value: '1' },
              ],
              [
                { title: '开始2', value: '2' },
                { title: '结束2', value: '3' },
              ],
            ],
            // span: '24',
            // styleRow: { width: '30%' },
          },
        ]}
        onQuery={(e) => {
          console.log(e);
        }}
        onClear={(e) => {
          console.log(e);
        }}
      />
    </div>
  );
};
